package cn.iocoder.yudao.module.reading.controller.app.book.vo;

import cn.iocoder.yudao.module.reading.framework.vo.BaseUrlConvertVO;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 绘本 Response VO
 *
 * @author 芋道源码
 */
@Schema(description = "用户 APP - 绘本 Response VO")
@Data
@EqualsAndHashCode(callSuper = false)
public class PictureBookRespVO extends BaseUrlConvertVO {

    @Schema(description = "绘本ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
    private Long id;

    @Schema(description = "绘本标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "At School")
    private String title;

    @Schema(description = "封面图片URL", example = "https://example.com/book1.jpg")
    private String cover;

    @Schema(description = "页数", requiredMode = Schema.RequiredMode.REQUIRED, example = "8")
    private Integer pages;

    @Schema(description = "在绘本集中的排序", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
    private Integer sortOrder;

    @Schema(description = "所属绘本集ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
    private Long bookSetId;

    @Schema(description = "所属绘本集标题", example = "牛津树1级")
    private String bookSetTitle;

    @Schema(description = "阅读状态")
    private ReadStatusVO readStatus;

    @Schema(description = "阅读状态")
    @Data
    public static class ReadStatusVO {
        @Schema(description = "是否已读", example = "false")
        private Boolean isRead;

        @Schema(description = "阅读次数", example = "0")
        private Integer readCount;

        @Schema(description = "最后阅读时间", example = "2024-01-01T10:30:00Z")
        private String lastReadAt;

        @Schema(description = "阅读进度", example = "0.6")
        private Double readProgress;
    }

    /**
     * 转换URL字段
     * 将相对路径转换为完整URL
     */
    @Override
    public void convertUrls() {
        this.cover = convertUrl(this.cover);
    }
}
